package com.whlilong.jxc.mina.util;


import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.FutureTask;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class ThreadPool {

	private static int extendsCount = 4;
	private static ThreadPoolExecutor threadPool = new ThreadPoolExecutor(
			extendsCount, 20, 0, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(1),
			new ThreadPoolExecutor.CallerRunsPolicy());

	public static ThreadPoolExecutor getThreadPool() {
		return threadPool;
	}

	public static int getExtendsCount() {
		return extendsCount;
	}

	public static void setExtendsCount(int extendsCount) {
		ThreadPool.extendsCount = extendsCount;
	}
	public static void threadPool(FutureTask<Object> task) {
		/*FutureTask<Object> task = new FutureTask<Object>(
				new Callable<Object>() {
					public Object call() throws Exception {
						logger.info("threadPool");
						return null;
					}

				});
		if (tasks != null) {
			tasks.add(task);
		}*/
		threadPool.execute(task);

	}
}
